<template>
  <view class="comment-section" id="comment-section">
    <view class="section-header">
      <view class="section-title">评论 ({{ comments.length }})</view>
    </view>
    
    <view class="comment-list" v-if="comments.length > 0">
      <comment-item 
        v-for="comment in comments" 
        :key="comment.id"
        :comment="comment"
      />
      <view class="list-footer" v-if="hasMore" @click="$emit('load-more')">
        <text>加载更多评论...</text>
      </view>
    </view>
    
    <view class="empty-comment" v-else>
      <text class="empty-text">暂无评论，快来发表第一条评论吧</text>
    </view>
  </view>
</template>

<script setup>
import CommentItem from './CommentItem.vue';

defineProps({
  comments: {
    type: Array,
    default: () => []
  },
  hasMore: {
    type: Boolean,
    default: false
  }
});

defineEmits(['load-more']);
</script>

<style lang="scss" scoped>
.comment-section {
  margin: 0 12px 12px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  background-color: #ffffff;
  
  .section-header {
    padding: 16px;
    border-bottom: 1px solid #f5f5f5;
    
    .section-title {
      font-size: 16px;
      font-weight: 600;
      color: #333333;
      display: flex;
      align-items: center;
      
      &:before {
        content: '';
        width: 4px;
        height: 16px;
        background-color: #007aff;
        margin-right: 8px;
        border-radius: 2px;
      }
    }
  }
  
  .comment-list {
    .list-footer {
      text-align: center;
      padding: 16px 0;
      font-size: 14px;
      color: #007aff;
      border-top: 1px solid #f5f5f5;
      
      &:active {
        background-color: #f5f5f5;
      }
    }
  }
  
  .empty-comment {
    padding: 40px 20px;
    text-align: center;
    
    .empty-text {
      font-size: 14px;
      color: #999999;
      line-height: 1.5;
    }
  }
}
</style>
